//
//  SSTabBarViewController.m
//  SS-FXYX
//
//  Created by paycloud110 on 16/4/22.
//  Copyright © 2016年 paycloud110. All rights reserved.
//

#import "SSTabBarViewController.h"
#import "MainViewController.h"
#import "PersonalCenterViewController.h"
#import "BrandViewController.h"
#import "DiscoverViewController.h"
#import "PersonalMessageViewController.h"
#import "SSNavigationViewController.h"

@interface SSTabBarViewController ()

@end

@implementation SSTabBarViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    
    
    
    [self setupChildController];
}
#pragma mark --<添加子控制器>
- (void)setupChildController
{
    MainViewController *MainController = [[MainViewController alloc] init];
    [self addChildViewController:MainController andWithTitle:@"首页" andWithImage:@"Fx_Home_HomeIcon" andWithSelectedImage:@"Fx_Home_HomeIcon2"];
    
    PersonalCenterViewController *PCController = [[PersonalCenterViewController alloc] init];
    [self addChildViewController:PCController andWithTitle:@"个人中心" andWithImage:@"Fx_Home_MineIcon" andWithSelectedImage:@"Fx_Home_MineIcon2"];
    
    PersonalMessageViewController *PMController = [[PersonalMessageViewController alloc] init];
    [self addChildViewController:PMController andWithTitle:@"消息" andWithImage:@"fx_Tab_nomassage" andWithSelectedImage:@"fx_Tab_massage"];
    BrandViewController *BrandController = [[BrandViewController alloc] init];
    [self addChildViewController:BrandController andWithTitle:@"品牌说" andWithImage:@"Fx_Home_Brand" andWithSelectedImage:@"Fx_Home_BrandSelected"];
    
    DiscoverViewController *discoverController = [[DiscoverViewController alloc] init];
    [self addChildViewController:discoverController andWithTitle:@"发现" andWithImage:@"Fx_Home_FindIcon" andWithSelectedImage:@"Fx_Home_FindIcon2"];
}
- (void)addChildViewController:(UIViewController *)childController andWithTitle:(NSString *)title andWithImage:(NSString *)normalImage andWithSelectedImage:(NSString *)selectedImage
{
    childController.title = title;
    
    NSMutableDictionary *normalDict = [[NSMutableDictionary alloc] init];
    normalDict[NSForegroundColorAttributeName] = [UIColor grayColor];
    normalDict[NSFontAttributeName] = [UIFont systemFontOfSize:10];
    [childController.tabBarItem setTitleTextAttributes:normalDict forState:UIControlStateNormal];
    
    NSMutableDictionary *selectedDict = [[NSMutableDictionary alloc] init];
    selectedDict[NSForegroundColorAttributeName] = [[UIColor alloc] initWithRed:54/255.0 green:185/255.0 blue:175/255.0 alpha:1];
    selectedDict[NSFontAttributeName] = [UIFont systemFontOfSize:10];
    [childController.tabBarItem setTitleTextAttributes:selectedDict forState:UIControlStateSelected];
    
    childController.tabBarItem.image = [UIImage imageNamed:normalImage];
    childController.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    SSNavigationViewController *SSNavController = [[SSNavigationViewController alloc] initWithRootViewController:childController];
    childController.tabBarItem.tag = 1;
    
    [self addChildViewController:SSNavController];
}
@end
